<template>
  <div class="settings-container">
    <div class="settings-box">
      <!-- head return-->
      <div class="settings-head">
        <van-nav-bar title="设置">
          <template #left>
            <van-icon name="arrow-left" size="24" color="black" @click="$router.push('/home/account')" />
          </template>
        </van-nav-bar>
      </div>

      <div class="settings-list">
        <van-collapse v-model="activeNames" :accordion="true">
          <van-collapse-item title="头像" name="1" size="50%">
            <div class="img-box">
              <div class="head-img">
                <van-uploader v-model="fileList" :show-upload="false" />
              </div>
              <div class="camera-box">
                <van-uploader capture="camera" :after-read="afterRead" :preview-image="false">
                  <van-icon name="photograph" />
                  <span>相机</span>
                </van-uploader>
              </div>
              <div class="photo-album">
                <van-uploader :after-read="afterRead" :preview-image="false">
                  <van-icon name="photo" />
                  <span>相册上传</span>
                </van-uploader>
              </div>
            </div>
          </van-collapse-item>

          <van-collapse-item title="姓名" name="2" value="奎sir">
            <div class="name-box">
              <input type="text" placeholder="请输入姓名">
              <button>确定</button>
            </div>
          </van-collapse-item>

          <van-collapse-item title="用户名" name="3" value="order_demo">
            <div class="user-box">
              <input type="text" placeholder="请输入用户名">
              <button>确定</button>
            </div>
          </van-collapse-item>

          <van-collapse-item class="email" title="邮箱" name="4" value="未绑定邮箱">
            <div class="email-box">
              <input type="text" placeholder="请输入邮箱">
              <button>确定</button>
            </div>
          </van-collapse-item>

          <van-collapse-item title="电话" name="5" value="+8618980082791">
            <div class="tel-box">
              <input type="Number" placeholder="请输入电话号码">
              <button>确定</button>
            </div>
          </van-collapse-item>

          <van-collapse-item title="IC编号" name="6">
            <div class="IC-box">
              <input type="Number" placeholder="请输入IC编号">
              <button>确定</button>
            </div>
          </van-collapse-item>

          <van-collapse-item title="性别" name="7">
            <div class="sex-box">
              <van-radio-group v-model="sexNum" direction="horizontal">
                <van-radio name="1">男</van-radio>
                <van-radio name="2">女</van-radio>
              </van-radio-group>
              <button>确定</button>
            </div>
          </van-collapse-item>

          <van-collapse-item title="语言偏好" name="8">
            <div class="lang-box">
              <van-radio-group v-model="language" direction="horizontal">
                <van-radio name="1">中文</van-radio>
                <van-radio name="2">English</van-radio>
              </van-radio-group>
              <button>确定</button>
            </div>
          </van-collapse-item>

          <van-collapse-item title="版本号" name="9" value="v1.02">没有更新</van-collapse-item>
          <van-collapse-item title="账户安全" name="10" right-icon>
            <div class="password-box">
              <div class="set-passw">
                <input type="text" placeholder="请输入密码">
                <button>设置密码</button>
              </div>
              <div class="original-passw">
                <input type="text" placeholder="请输入原密码">
              </div>
              <div class="modify-passw">
                <input type="text" placeholder="请输入新密码">
                <button>修改密码</button>
              </div>
            </div>
          </van-collapse-item>
        </van-collapse>
      </div>

      <div class="btn-box">
        <van-button type="primary" block>登出账户</van-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeNames: '0',
      language: '1',
      sexNum: '1',
      fileList: [
        {
          url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2F2021%2Fedpic_source%2F56%2Fea%2F6d%2F56ea6d00a3f63b051a9a6fa10e22c82a_13.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1641437513&t=f668ed5c61f1810af9e90c24a513dc7e'
        }
      ]
    }
  },
  methods: {
    afterRead(file) {
      this.fileList = []
      this.fileList.push(file)
    }
  }
}
</script>

<style lang="less" scoped>
.settings-box {
  position: absolute;
  max-width: 640px;
  width: 100%;
  height: 100%;
  z-index: 2;
  background-color: #ededed;
  .settings-head {
    position: fixed;
    max-width: 640px;
    width: 100%;
    z-index: 2;
  }
  .settings-list {
    position: relative;
    overflow: hidden;
    top: 46px;
    width: 97%;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 9px;
    z-index: 1;
    /deep/.van-cell__right-icon {
      margin-left: 0.9em;
    }
    /deep/.van-cell__value {
      color: #b0b0b0;
    }
    .img-box {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 160px;
      .head-img {
        overflow: hidden;
        width: 80px;
        height: 80px;
        border-radius: 50%;
        border: 0.06em solid #e3e3e3;
        margin-bottom: 0.6em;
        /deep/.van-uploader__input {
          position: absolute;
          width: 100%;
          height: 100%;
          opacity: 0.5;
        }
      }
      .camera-box,
      .photo-album {
        width: 90%;
        height: 30px;
        margin-top: 0.3em;
        border-bottom: 0.06em solid #e3e3e3;
        /deep/.van-icon-photo,
        .van-icon-photograph {
          margin-right: 0.6em;
        }
        /deep/.van-uploader {
          width: 100%;
          .van-uploader__input-wrapper {
            width: 100%;
          }
        }
      }
    }
    .email {
      /deep/.van-cell__value {
        color: orange;
      }
    }
    .name-box,
    .user-box,
    .email-box,
    .tel-box,
    .IC-box {
      display: flex;
      align-items: center;
      width: 100%;
      height: 27px;
      input:nth-child(1) {
        border: 0.06em solid #b0b0b0;
        border-radius: 6px;
        height: 100%;
        margin-right: 1em;
        text-indent: 0.6em;
      }
      button:nth-child(2) {
        border: none;
        background-color: orange;
        border-radius: 6px;
        height: 100%;
        width: 40px;
        color: white;
        font-size: 0.9em;
      }
    }
    .sex-box,
    .lang-box {
      display: flex;
      align-items: center;
      width: 100%;
      height: 27px;
      button:nth-child(2) {
        border: none;
        background-color: orange;
        border-radius: 6px;
        height: 100%;
        width: 40px;
        color: white;
        font-size: 0.9em;
      }
      .van-radio-group {
        margin-right: 1em;
        margin-left: 1em;
      }
      /deep/.van-radio__icon--checked .van-icon {
        background-color: orange;
        border: orange;
      }
    }
    .password-box {
      display: flex;
      flex-direction: column;
      justify-content: center;
      width: 100%;
      height: 110px;
      .set-passw,
      .original-passw,
      .modify-passw {
        display: flex;
        align-items: center;
        width: 100%;
        height: 27px;
        margin-bottom: 0.3em;
        margin-top: 0.3em;
        input:nth-child(1) {
          border: 0.06em solid #b0b0b0;
          border-radius: 6px;
          height: 100%;
          margin-right: 1em;
          text-indent: 0.6em;
        }
        button:nth-child(2) {
          border: none;
          background-color: orange;
          border-radius: 6px;
          height: 100%;
          width: 60px;
          color: white;
          font-size: 0.9em;
        }
      }
    }
  }
  .btn-box {
    display: flex;
    justify-content: center;
    position: relative;
    top: 44px;
    width: 100%;
    height: 330px;
    background-color: #ededed;
    .van-button--primary {
      position: absolute;
      top: 20px;
      width: 97%;
      border-radius: 9px;
      border: none;
      background-color: orange;
    }
  }
}
</style>
